import React from 'react'
import { connect } from 'dva'
import { Menu } from 'antd'




class MenuList extends React.Component {
		state = {
				current: this.props.location.query.tag||this.props.menus[0].key,
		}
		handleClick = (e) => {
				const payload=this.props.location
				payload.query={}
				e.key&&(payload.query.tag=e.key)

				this.props.changeRouter(payload)
				this.setState({
						current: e.key,
				});
				// if()
				// dispatch({
		  //     type: `portfolio/getBenchList`,
		  //     payload
		  //   })
		}


		render() {
				return (
						<Menu
								onClick={this.handleClick}
								selectedKeys={[this.state.current]}
								mode="horizontal"
						>
						{
								this.props.menus.map(item=><Menu.Item key={item.key}>{item.text}</Menu.Item>)
						}
						</Menu>
				)
		}
}

MenuList.defaultProps = {
		menus:[],
		changeRouter:function(){}
}

export default connect()(MenuList)
